import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']  # 解决中文乱码问题
plt.rcParams['axes.unicode_minus'] = False

dates = list(range(1, 16))

min_temps = [22, 23, 24, 25, 24, 25, 24, 23, 22, 23, 24, 25, 24, 23, 22]
max_temps = [29, 30, 31, 32, 33, 34, 31, 30, 29, 30, 32, 33, 31, 30, 29]

plt.figure(figsize=(10, 6))
plt.plot(dates, min_temps, label='最低气温', color='blue')
plt.plot(dates, max_temps, label='最高气温', color='red')
plt.xlabel('日期')
plt.ylabel('值')
plt.title('清远市未来15天的最低气温和最高气温折线图')
plt.legend()
plt.grid(linestyle='--',alpha=0.5)
for i, txt in enumerate(max_temps):
    plt.annotate(f'{txt}℃',(dates[i], max_temps[i]), textcoords="offset points",color="red",xytext=(0,15),ha='center')
for i,txt in enumerate(min_temps):
    plt.annotate(f'{txt}℃',(dates[i],min_temps[i]),textcoords="offset points",color="blue",xytext=(0,-15),ha='center')
plt.savefig('temp_forecast.png')
plt.show()